/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ar.com.wholeconsulting.pacc.gui.utils.table;

import java.awt.Component;
import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author pable
 */
public class JCheckboxCellRenderer implements TableCellRenderer{

    private JCheckBox checkbox;
    
    public JCheckboxCellRenderer() {
        checkbox = new JCheckBox();
        //checkbox.setOpaque(true);
    }
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        if(!isSelected){
            checkbox.setForeground(table.getForeground());
            checkbox.setBackground(table.getBackground());
        }else{
            checkbox.setForeground(table.getSelectionForeground());
            checkbox.setBackground(table.getSelectionBackground());
        }
        if(value instanceof Boolean){
            checkbox.setSelected((Boolean)value);
        }
        return checkbox;
    }

}
